<template>
	<view class="wrap">
		<view v-if="isInit" v-cloak>
			<noRecord v-if="menuInfo.list.length == 0" :info="info" v-cloak></noRecord>
			<menuList v-else :menuInfo="menuInfo" @loadMore="addPage"></menuList>
		</view> 
	</view>
</template>
<script>
import menuList from '@/wxcomponents/commonLayout/menuList.vue';
import noRecord from '@/wxcomponents/commonLayout/noRecord.vue';
import { fommat } from '@/libs/common.js';
import dictMixins from '@/libs/dictMixins.js'
export default {
	mixins: [dictMixins],
	data() {
		return {
			isInit: false,
			info: '没有申请记录!',
			menuInfo: {
				base: {
					menuProp: ['dinnerTime', 'dinnerNumbers', 'status'],
					tit: ['时间', '人数', '状态'],
					class: 'threeCol',
					loadMore: true
				},
				list: []
			},
			pageParams: {
				pageNum: 1,
				pageSize: 20
			}
		};
	},
	onLoad() {
		this.getList();
	},
	methods: {
		//申请状态
		async getList(e) {
			let resp = await this.$http.post({
				url: '/oa/wechat/dinnerApply/page',
				data: this.pageParams
			});
			let list = resp.result.records || resp.result.rows;
			if (list.length < this.pageParams.pageSize || list.length == 0) {
				this.menuInfo.base.loadMore = false;
			}
			this.menuInfo.list = list.map(item => {
				item.detailType = 'detail'
				let obj = {
					url: `detail?data=${JSON.stringify(item)}`,
					dinnerNumbers: item.dinnerNumbers,
					dinnerTime: item.dinnerTime.substring(0, 10),
					status: this.getDictNameWithCodeAndValue('dict_apply_status', item.applyStatus),
					data: item,
				}
				return obj;
			});
			this.isInit = true;
		},
		// 加载下一页
		addPage() {
			this.pageParams.pageNum++;
			this.getList();
		}
	},
	components: { menuList, noRecord }
};
</script>

<style lang="scss" scoped>
[v-cloak] {
	display: none !important;
}
</style>
